package health

import (
	"gitcode.com/G-YT/ANN/server/model/topic"
	"gitcode.com/G-YT/ANN/server/model/user"
	"time"
)

// Circle 健康圈结构体
type Circle struct {
	Cid        uint            `json:"c_id" form:"c_id" gorm:"column:c_id;primarykey"`  //健康圈ID
	Uid        uint            `json:"u_id" gorm:"column:u_id"`                         //用户ID
	Tid        uint            `json:"t_id" form:"tid" gorm:"column:t_id"`              //所属版块ID
	Topic      topic.Topic     `json:"-" gorm:"foreignKey:ID;references:Tid;"`          //话题相关
	Text       string          `json:"text" form:"text" gorm:"column:text"`             //文本
	Img        string          `json:"img" gorm:"column:img"`                           //图片
	CreatedAt  time.Time       `json:"create_at" gorm:"column:create_at"`               //创建时间
	Views      uint            `json:"views" gorm:"column:views;default:0"`             //浏览量
	PraiseNum  uint            `json:"praise_num" gorm:"column:praise_num;default:0"`   //点赞数
	CommentNum uint            `json:"comment_num" gorm:"column:comment_num;default:0"` //评论数
	User       user.User       `json:"-" gorm:"foreignKey:Uid;references:ID;"`          //关联用户
	Replays    []CircleComment `json:"-" gorm:"foreignKey:Cid;references:Cid;"`         //健康圈的评论
	IsPraise   bool            `json:"isPraise" gorm:"-"`                               //是否点赞
}

// CircleComment 健康圈评论结构体
type CircleComment struct {
	ID        uint      `gorm:"column:id;primarykey"`                               //评论ID
	CreatedAt time.Time `json:"create_at" form:"create_at" gorm:"column:create_at"` //创建时间
	Uid       uint      `json:"u_id" form:"u_id" gorm:"column:u_id"`                //用户ID
	ReplyID   uint      `json:"reply_id" gorm:"column:reply_id;default:0"`          //评论父级ID  0
	Text      string    `json:"text" form:"text" gorm:"column:text"`                //评论
	ToUid     uint      `json:"to_uid"  gorm:"column:to_u_id"`                      //被评论&回复的用户ID
	Cid       uint      `json:"c_id" form:"c_id" gorm:"column:c_id"`                //健康圈ID
	User      user.User `gorm:"->;foreignKey:Uid"`
	ToUser    user.User `gorm:"->;foreignKey:ToUid"`
}

// CircleReportRecord 健康圈举报记录结构体
type CircleReportRecord struct {
	ID        uint      `gorm:"column:id;primarykey"`              //健康圈ID
	Uid       uint      `json:"u_id" gorm:"column:u_id"`           //用户ID
	CreatedAt time.Time `json:"create_at" gorm:"column:create_at"` //创建时间
}

type CircleLike struct {
	UserID    uint `json:"userID" form:"userID" gorm:"primarykey;column:user_id;comment:用户id;size:10;"`
	CID       uint `json:"Cid" form:"Cid" gorm:"column:c_id;comment:健康圈id;size:10;"`
	TopicType uint `json:"topic_type" form:"topicType" gorm:"column:topic_type;comment:话题类型;size:10;"`
}

func (CircleLike) TableName() string {
	return "fd_circle_like"
}

func (Circle) TableName() string {
	return "fd_circle"
}

func (CircleComment) TableName() string {
	return "fd_circle_comments"
}

func (CircleReportRecord) TableName() string {
	return "fd_circle_report_record"
}
